package com.pro.service.imple;

import com.pro.mapper.JsMenuLoginRecordMapper;
import com.pro.pojo.JsLoginRecord;
import com.pro.service.JsMenuLoginRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:JsMenuLoginRecordServiceImple
 * Package:com.pro.service.imple
 * Description:
 *
 * @Date:2022/3/18 下午 2:54
 * @Author: WYH
 */
@Service
public class JsMenuLoginRecordServiceImple implements JsMenuLoginRecordService {

    @Autowired(required = false)
    private JsMenuLoginRecordMapper jsMenuLoginRecordMapper;

    /**
     * @Author WYH
     * @Description //TODO 查询后台人员登录日志
     * @Date 下午 3:00 2022/3/18
     * @Param account，trueName，limit，page
     * @return  List<JsLoginRecord>
     **/
    @Override
    public List<JsLoginRecord> getAllJsLoginRecord(String account, String trueName, Integer loginType,Integer limit, Integer page) {
        page = (page-1)*limit;
        List<JsLoginRecord> allJsLoginRecord = jsMenuLoginRecordMapper.getAllJsLoginRecord(account, trueName, loginType,limit, page);
        return allJsLoginRecord;
    }

    /**
     * @Author WYH
     * @Description //TODO 计算后台人员登录日志个数
     * @Date 下午 3:16 2022/3/18
     * @Param account，trueName，loginType
     * @return  Integer
     **/
    public Integer countLoginRecord(String account,String trueName,Integer loginType){
        Integer integer = jsMenuLoginRecordMapper.countLoginRecord(account, trueName, loginType);
        return integer;
    }

    /**
     * @Author WYH
     * @Description //TODO 查询前台人员登录日志
     * @Date 下午 3:40 2022/3/18
     * @Param account，nickname，limit，page
     * @return  List<JsLoginRecord>
     **/
    public List<JsLoginRecord> getAllJsLoginRecordbefore(String account,String nickname,Integer loginType,Integer limit,Integer page){
        page = (page-1)*limit;
        List<JsLoginRecord> allJsLoginRecordbefore = jsMenuLoginRecordMapper.getAllJsLoginRecordbefore(account, nickname, loginType, limit, page);
        return allJsLoginRecordbefore;
    }

    /**
     * @Author WYH
     * @Description //TODO 计算前台人员登录日志个数
     * @Date 下午 3:55 2022/3/18
     * @Param account，nickname ,loginType
     * @return Integer
     **/
    public Integer countLoginRecordbefore(String account,String nickname,Integer loginType){
        Integer integer = jsMenuLoginRecordMapper.countLoginRecordbefore(account, nickname, loginType);
        return integer;
    }

    /**
     * @Author WYH
     * @Description //TODO 删除登录日志
     * @Date 下午 4:25 2022/3/18
     * @Param id
     * @return true | false
     **/
    public Boolean delLooginUser(Integer id){
        Boolean aBoolean = jsMenuLoginRecordMapper.delLooginUser(id);
        return aBoolean;
    }
}
